package com.hongyuan.venue.ui.home.fragment;

import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.ViewGroup;
import androidx.annotation.Nullable;
import androidx.lifecycle.ViewModelProviders;
import com.hongyuan.venue.R;
import com.hongyuan.venue.base.AppViewModelFactory;
import com.hongyuan.venue.base.CustomFragment;
import com.hongyuan.venue.databinding.FragmentHomeScheduledBinding;
import com.hongyuan.venue.ui.home.view_mode.HomeScheduledViewModel;

import me.tatarka.bindingcollectionadapter2.BR;

public class HomeScheduledFragment extends CustomFragment<FragmentHomeScheduledBinding, HomeScheduledViewModel>{


    @Override
    public int initContentView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
        return R.layout.fragment_home_scheduled;
    }

    @Override
    public int initVariableId() {
        return BR.viewModel;
    }

    @Override
    public HomeScheduledViewModel initViewModel() {
        //使用自定义的ViewModelFactory来创建ViewModel，如果不重写该方法，则默认会调用NetWorkViewModel(@NonNull Application application)构造方法
        AppViewModelFactory factory = AppViewModelFactory.getInstance(getActivity().getApplication());
        return ViewModelProviders.of(this, factory).get(HomeScheduledViewModel.class);
    }

    @Override
    public void initView() {
        super.initView();
        String datas = getMyString("dates");
        viewModel.setData(datas);

        viewModel.gcId.set(getMyArgumentsString("gc_id"));
    }
}
